/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Candidato;
import br.com.modelo.Endereco1;
import java.util.GregorianCalendar;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author egberto
 */
public class AdicionaCandidatoEndereco {
    
    public static void main(String args[]){
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager manager = factory.createEntityManager();
        
        manager.getTransaction().begin();
        
        Endereco1 e = new Endereco1();
        e.setEstado("São Paulo");
        e.setCidade("São Paulo");
        e.setLogradouro("Av. Brigadeiro Faria Lima");
        e.setNumero(1571);
        
        Candidato p = new Candidato();
        p.setNome("Rafael justino");
        p.setNascimento(new GregorianCalendar(1984,10,30));
        p.setEndereco(e);
        
        manager.persist(p);
        
        manager.getTransaction().commit();
        
        manager.close();
        factory.close();
        
    }
    
}
